package com.zerui.manager.web;

import com.alibaba.fastjson.JSONObject;
import com.zerui.authority.annotation.Authorize;
import com.zerui.cola.dto.PageResponse;
import com.zerui.cola.dto.Response;
import com.zerui.manager.web.cmd.AccessRecordQryCmd;
import com.zerui.manager.web.vo.AccessRecordVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

/**
 * @Author wh
 * @create_time 2023-08-23 15:33
 */
@Validated
@Api(value = "通行记录", tags = "门禁设备管理")
@RestController
@RequestMapping("/api/v1/access/record")
@Authorize(value = {"access-control-manager:admin-record"})
public class AccessRecordController {

    @Resource
    private AccessRecordService accessRecordService;

    @ApiOperation(value = "通行记录分页列表", tags = "门禁授权管理")
    @PostMapping("/getPageList")
    public PageResponse<AccessRecordVO> getPageList(@RequestBody @Validated AccessRecordQryCmd accessRecordQryCmd) {
        return accessRecordService.getPageList(accessRecordQryCmd);
    }

    @PostMapping("/export")
    @ApiOperation(value = "通行记录列表导出",tags = "门禁授权管理")
    @ResponseBody
    public void employeeExport(@RequestBody @Validated AccessRecordQryCmd accessRecordQryCmd, HttpServletResponse response) {
        accessRecordService.getAccessRecordListExport(accessRecordQryCmd,response);
    }


}
